<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>continue和break区别</title>
  </head>
  <body>
    <script>
      // continue使用：continue是退出当前次循环，继续执行下一次循环
      var sum = 0;
      for (var i = 1; i <= 10; i++) {
        if (i % 3 === 0) {
          continue;
        } else {
          sum += i;
        }
      }
      console.log('sum--', sum);

      // break使用：break是直接退出整个循环
      var sum2 = 0;
      for (var e = 1; e <= 10; e++) {
        if (e % 3 === 0) {
          break;
        } else {
          sum2 += e;
        }
      }
      console.log('sum2--', sum2);
    </script>
  </body>
</html>
